{include file='head'/}
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="red"> * </span>插件标识</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入插件唯一标识。示例：demo"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="red"> * </span>插件名称</label>
                <div class="layui-input-block">
                    <input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="演示插件"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="red"> * </span>插件版本</label>
                <div class="layui-input-block">
                    <input type="text" name="version" lay-verify="required" autocomplete="off" placeholder="示例：1.0.0"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">插件图标</label>
                <div class="layui-input-block">
                    <input type="text" name="icon" autocomplete="off" placeholder="示例："
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="red"> * </span>插件作者</label>
                <div class="layui-input-block">
                    <input type="text" name="author" lay-verify="required" autocomplete="off" placeholder="示例：小灰灰"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">前台地址</label>
                <div class="layui-input-block">
                    <input type="text" name="home" autocomplete="off" placeholder="如有前台地址请填写 例如/demo/index"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">菜单配置</label>
                    <div class="layui-input-block">
                        <input type="radio" name="menu" value="1" title="开启" checked>
                        <input type="radio" name="menu" value="0" title="关闭">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">插件配置</label>
                    <div class="layui-input-block">
                        <input type="radio" name="config" value="1" title="开启" checked>
                        <input type="radio" name="config" value="0" title="关闭">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">插件简介</label>
                <div class="layui-input-block">
                    <textarea placeholder="如不需要菜单项(可选)关闭，适合简易型插件应用" class="layui-textarea" id="intro"
                              name="intro"></textarea>
                </div>
            </div>

        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="admin-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>

{include file='footer'/}
<script>
  layui.use(['form', 'jquery'], function () {
    let form = layui.form;
    let $ = layui.jquery;
    form.on('submit(admin-save)', function (data) {
      $.ajax({
        url: "{:__url('plugin/index/add')}",
        data: JSON.stringify(data.field),
        dataType: 'json',
        contentType: 'application/json',
        type: 'post',
        success: function (res) {
          if (res.code === 200) {
            hui_msg(res.msg, 1, function () {
              window.location.reload();
            });
          } else {
            hui_msg(res.msg, 2);
          }
        }
      })
      return false;
    });
  })
</script>
<script>
</script>
</body>
</html>
